<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="../common/tag.jsp"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	 String searchText = request.getParameter("title");
	 if(searchText != null){
		 searchText=new String(searchText.getBytes("ISO8859_1"),"utf-8");  
	 }
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<meta name="content-type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>站类搜索_阅学网</title>
<meta name="Keywords"
	content="软件开发、编程、程序员、码伦">
<meta name="description" content="Java、C、C++、软件开发、编程、程序员、.NET">
<%@ include file="../common/common.jsp"%>
<script src="js/public/article.js"></script>
</head>
<body>
	<div class="index-top">
		<div class="index-top-left">
			<a href="public/index" style="color: #00BC3E;">返回首页</a>
		</div>
		<!-- 顶部 -->
	<div class="index-top-right">
			<c:choose>
					<c:when test="${user ==null || user.username.matches('_[0-9]+')}">
						<span style="color: #20C0FC;" id="no-login">你还未登录</span>
						<a href="javascript:void(0);" onclick="javascript:$.util.login();" 	target="_self" id="lj-login">,立即登录</a>&nbsp;
						<a href="public/user/register" style="color: #FF7A32;" id="free-login">免费注册</a>&nbsp;
					</c:when>
					<c:otherwise>
						<span style="color: #0099FF;">欢迎你,${user.chName }</span>&nbsp;&nbsp;
						<a href="user/index" target="_black" title="个人中心">个人中心</a>
					</c:otherwise>
			</c:choose>
			&nbsp; <a href="" id="jrsc" target="_blank">一键分享</a>
			&nbsp; <a href="javascript:$.util.alert('等待开发中...');">安卓版下载</a>
		</div>
	</div>
	<div class="yc_container" style="text-align: center;height: 1500px;">
		<div style="float: left;">
				<div class="search-img" >
					<img alt="" style="width: 199px;height: 80px;margin-left: 20px;" src="images/reading-study.png" />
				</div>
				<div class="search-text-btn">
					<div class="search-text-btn-1" style="float: left;">
							<input type="text" name="searchText" id="searchText"  placeholder="请输入搜索的内容" value="<%=searchText %>">
					</div>
					<div class="search-text-btn-2" style="float: left;">
							<button id="search-list-btn">搜&nbsp;&nbsp;索</button>
					</div>
				</div>
		</div>
		<div class="search-result-list">
			<span>结果: 找到 "<%=searchText %>" 相关内容 ${page.totalCount} 个</span>
		</div>
		<div style="float: left;height: 1200px;">
			<ul>
					<c:forEach items="${searchTextList}" var="searchText">
						<li style="height: 104px;margin-bottom: 15px;">
								<div style="float: left;height: 80px;margin-left: 10px;">
										<div class="search-detail-title">
												<c:if test="${searchText.resultType ==1 }">
													<a href="public/article/detail/${searchText.id }" target="_blank" title="${searchText.title }">${searchText.title }</a>
												</c:if>
												<c:if test="${searchText.resultType ==2 }">
													<a href="public/resource/detail/${searchText.id }" target="_blank" title="${searchText.title }">${searchText.title }</a>
												</c:if>
												<c:if test="${searchText.resultType ==3 }">
													<a href="public/book/detail/${searchText.id }" target="_blank" title="${searchText.title }">${searchText.title }</a>
												</c:if>
										</div>
										<div style="float: left;width: 100%;">
								                <span style="color: #5CB85C;float: left;">
									                <c:if test="${searchText.resultType ==1 }">浏览:${searchText.count }</c:if>
									                <c:if test="${searchText.resultType ==2 }">下载:${searchText.count }</c:if>
									                <c:if test="${searchText.resultType ==3 }">阅读:${searchText.count }</c:if>
								                </span>&nbsp;&nbsp;
										</div>
										<div style="float: left;width: 100%;margin-bottom: 8px;">
								                <div style="width: 620px;font-size: 13px;height: 30px;margin-top: 5px;text-align: left;">
							                			${fn:substring(searchText.content, 0, 60)} 
								                </div>
										</div>
										<div style="float: left;width: 100%;">
												<span style="font-size: 12px;float: left;color: #3A8000;">
													<fmt:formatDate value="${searchText.createDate }" type="both" pattern="yyyy-MM-dd HH:mm:ss" />
													-${searchText.resultTypeCn }
												</span>
										</div>
								</div>
						</li>
					</c:forEach>
			</ul>
		</div>
		<div>
			<div class="pagination-bar">
						<div class="pagination-bar-left"><span>共&nbsp;${page.totalCount}&nbsp;条记录&nbsp;第${page.pageNow}页</span></div>
						<div class="pagination-bar-right" style="margin-right: 400px;">
							<span><a href="public/searchList?searchText=<%=searchText %>&pageNow=1">首页</a></span>
							<c:choose>
								<c:when test="${page.pageNow -1 >0}">
									<span>
										<a href="public/searchList?searchText=<%=searchText %>&pageNow=${page.pageNow-1}">&lt;</a>
									</span>
								</c:when>
							</c:choose>
							<%-- 计算页码列表的开始和结束位置，即两个变量begin和end --%>
							<c:choose>
								<c:when test="${page.totalPageCount <=2}">
									<c:set var="begin" value="1"></c:set>
									<c:set var="end" value="${page.totalPageCount }"></c:set>
								</c:when>
								<c:otherwise>
									<c:set var="begin" value="${page.pageNow-2 }"/>
	 								<c:set var="end" value="${page.pageNow + 2}"/>
	 								<c:if test="${begin <=1 }">
										<c:set var="begin" value="1"/>
	 								</c:if>
	 								<c:if test="${end>=page.totalPageCount }">
	 									<c:set var="end" value="${page.totalPageCount }"/>
	 								</c:if>
								</c:otherwise>
							</c:choose>
							<%--页码 --%>
							<c:forEach begin="${begin }" end="${end}" var="pageIndex">
									<c:choose>
										<c:when test="${page.pageNow==pageIndex}">
											<span>
												<a href="javascript:void(0);"style="float: left; background: #EAEAEA;">${pageIndex }</a>
											</span>
										</c:when>
										<c:otherwise>
											<span>
												<a href="public/searchList?searchText=<%=searchText %>&pageNow=${pageIndex}" target="_self">${pageIndex }</a>
											</span>
										</c:otherwise>
									</c:choose>
							</c:forEach>
							<%-- 显示当前页后面点点点 --%>
							<c:if test="${end< page.totalPageCount}">
								<span>
									<a  href="javascript:void(0);">...</ a>
								</span>
							</c:if>
							<c:choose>
								<c:when test="${page.pageNow <page.totalPageCount}">
									<span>
										<a href="public/searchList?searchText=<%=searchText %>&pageNow=${page.pageNow+1 }" target="_self">&gt;</a>
									</span>
								</c:when>
							</c:choose>
							<span>
								<a href="public/searchList?searchText=<%=searchText %>&pageNow=${page.totalPageCount}">末页</a>
							</span>
					</div>
				</div>
		</div>
     </div>
	<jsp:include page="/public/bottom.jsp"></jsp:include>
</body>
</html>
